﻿
@page "/Wms/SaleReturnInWarehouseDetail/BatchEdit"
@using nERP.ViewModel.Wms.SaleReturnInWarehouseDetailVMs
@using System.ComponentModel.DataAnnotations
@inherits BasePage

<ValidateForm @ref="vform" Model="@Model" OnValidSubmit="@Submit">
  <div style="margin-bottom:10px;"> @WtmBlazor.Localizer["Sys.BatchEditConfirm"]</div>
  <Row ItemsPerRow="ItemsPerRow.Two" RowType="RowType.Normal">
    <BootstrapInput @bind-Value="@Model.LinkedVM.Seq"/>
    <Select @bind-Value="@Model.LinkedVM.SaleReturnInWarehouseId" Items="AllSaleReturnInWarehouses" Id="gf4165700595f43bb8a9c2faf4a005e48"/>
    <Select @bind-Value="@Model.LinkedVM.SaleReturnId" Items="AllSaleReturns" Id="gb1b107b1708b4cc49277a6a57aa71229"/>
    <Select @bind-Value="@Model.LinkedVM.SaleReturnDetailId" Items="AllSaleReturnDetails" Id="gbddd0f3635a2436d988a6e9b30a97991"/>
    <Select @bind-Value="@Model.LinkedVM.WarehouseId" Items="AllWarehouses" Id="ga56233f4af164c1ab06e488ae6f73a3a"/>
    <Select @bind-Value="@Model.LinkedVM.GoodsId" Items="AllGoodss" Id="g57a275bc1143439cab259c9c86dd360c"/>
    <BootstrapInput @bind-Value="@Model.LinkedVM.GoodsName"/>
    <BootstrapInput @bind-Value="@Model.LinkedVM.GoodsSpec"/>
    <BootstrapInput @bind-Value="@Model.LinkedVM.GoodsUnit"/>
    <BootstrapInput @bind-Value="@Model.LinkedVM.ReturnNumber"/>
    <BootstrapInput @bind-Value="@Model.LinkedVM.Remark"/>
  </Row>

  <div class="modal-footer table-modal-footer">
    <Button ButtonType="ButtonType.Submit" IsAsync="true" Text="@WtmBlazor.Localizer["Sys.Submit"]"/>
    <Button OnClick="OnClose" Text="@WtmBlazor.Localizer["Sys.Close"]"/>
  </div>

</ValidateForm>



@code {
    [Parameter]
    public string id { get; set; }
    [Parameter]
    public string[] ids { get; set; }
    private SaleReturnInWarehouseDetailBatchVM Model = new SaleReturnInWarehouseDetailBatchVM();
    private ValidateForm vform { get; set; }
    
    private async Task Submit(EditContext context)
    {
        Model.Ids = ids;
        await PostsForm(vform, "/api/Wms/SaleReturnInWarehouseDetail/BatchEdit", (s) => WtmBlazor.Localizer["Sys.BatchEditSuccess", s], method: HttpMethodEnum.POST);
    }
            

    public void OnClose()
    {
        CloseDialog();
    }
    
    private List<SelectedItem> AllSaleReturnInWarehouses = new List<SelectedItem>();
    private List<SelectedItem> AllSaleReturns = new List<SelectedItem>();
    private List<SelectedItem> AllSaleReturnDetails = new List<SelectedItem>();
    private List<SelectedItem> AllWarehouses = new List<SelectedItem>();
    private List<SelectedItem> AllGoodss = new List<SelectedItem>();
    protected override async Task OnInitializedAsync()
    {
        
        
        AllSaleReturnInWarehouses = await WtmBlazor.Api.CallItemsApi("/api/Wms/SaleReturnInWarehouseDetail/GetSaleReturnInWarehouses");
        AllSaleReturnInWarehouses.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"],Value = "" });
        AllSaleReturns = await WtmBlazor.Api.CallItemsApi("/api/Wms/SaleReturnInWarehouseDetail/GetSaleReturns");
        AllSaleReturns.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"],Value = "" });
        AllSaleReturnDetails = await WtmBlazor.Api.CallItemsApi("/api/Wms/SaleReturnInWarehouseDetail/GetSaleReturnDetails");
        AllSaleReturnDetails.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"],Value = "" });
        AllWarehouses = await WtmBlazor.Api.CallItemsApi("/api/Wms/SaleReturnInWarehouseDetail/GetWarehouses");
        AllWarehouses.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"],Value = "" });
        AllGoodss = await WtmBlazor.Api.CallItemsApi("/api/Wms/SaleReturnInWarehouseDetail/GetGoodss");
        AllGoodss.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"],Value = "" });

        await base.OnInitializedAsync();
    }
}
